trial countdown#2030
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Internal previewPreview URL: https://mcp-inspector-pr-2030.up.railway.app |
WalkthroughThis change introduces trial countdown functionality to the MCP sidebar. A new Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
mcpjam-inspector/client/src/components/sidebar/__tests__/sidebar-invite-cta.test.tsx (1)
11-14: ⚡ Quick winPlease add one active-trial test path in this suite.
Line 13 hardcodes
useQuerytoundefined, so the newSidebarTrialCountdownbranch is never validated here. A single case mocking an active trial payload (end date + status) and asserting countdown render plus upgrade navigation would close that gap.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@mcpjam-inspector/client/src/components/sidebar/__tests__/sidebar-invite-cta.test.tsx` around lines 11 - 14, Add one test case to the sidebar-invite-cta.test.tsx suite that covers the active-trial branch by mocking useQuery to return an active trial payload (include a future end date and status "active") instead of undefined; in that test render the SidebarTrialCountdown (via the existing component tree in the test), assert the countdown text or timer is present, and assert the upgrade navigation element (button/link) is rendered and triggers the expected navigation callback; reuse the existing mockUseConvexAuth setup and only override useQuery for this single test so other tests remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@mcpjam-inspector/client/src/components/sidebar/sidebar-trial-countdown.tsx`:
- Around line 18-23: In the sidebar-trial-countdown component useEffect, the
interval is computed once from trialEndsAt so the tick cadence never tightens
when remaining time drops below an hour; change the logic to schedule/reschedule
on each tick (for example replace the fixed setInterval with a self-rescheduling
timer or clear-and-set a new timer inside the callback) so you compute remaining
= trialEndsAt - Date.now() on every tick and choose 1000ms or 60000ms
accordingly; ensure you still call setNow(Date.now()) each tick and properly
clear the timeout/interval in the cleanup to avoid leaks (refer to useEffect,
setNow, the interval id variable).
---
Nitpick comments:
In
`@mcpjam-inspector/client/src/components/sidebar/__tests__/sidebar-invite-cta.test.tsx`:
- Around line 11-14: Add one test case to the sidebar-invite-cta.test.tsx suite
that covers the active-trial branch by mocking useQuery to return an active
trial payload (include a future end date and status "active") instead of
undefined; in that test render the SidebarTrialCountdown (via the existing
component tree in the test), assert the countdown text or timer is present, and
assert the upgrade navigation element (button/link) is rendered and triggers the
expected navigation callback; reuse the existing mockUseConvexAuth setup and
only override useQuery for this single test so other tests remain unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f992eec3-2040-4247-ba11-074039373798
📒 Files selected for processing (3)
mcpjam-inspector/client/src/components/mcp-sidebar.tsxmcpjam-inspector/client/src/components/sidebar/__tests__/sidebar-invite-cta.test.tsxmcpjam-inspector/client/src/components/sidebar/sidebar-trial-countdown.tsx
| useEffect(() => { | ||
| const remaining = trialEndsAt - Date.now(); | ||
| const interval = remaining < 60 * 60 * 1000 ? 1_000 : 60_000; | ||
| const id = window.setInterval(() => setNow(Date.now()), interval); | ||
| return () => window.clearInterval(id); | ||
| }, [trialEndsAt]); |
There was a problem hiding this comment.
Countdown cadence never tightens in the final hour.
Line 20 computes the interval only once per trialEndsAt, so a trial that starts with >1h left keeps a 60s tick even when the UI shows seconds. Re-schedule based on current remaining time each tick.
Suggested fix
- useEffect(() => {
- const remaining = trialEndsAt - Date.now();
- const interval = remaining < 60 * 60 * 1000 ? 1_000 : 60_000;
- const id = window.setInterval(() => setNow(Date.now()), interval);
- return () => window.clearInterval(id);
- }, [trialEndsAt]);
+ useEffect(() => {
+ const remaining = trialEndsAt - now;
+ if (remaining <= 0) return;
+
+ const delay = remaining < 60 * 60 * 1000 ? 1_000 : 60_000;
+ const id = window.setTimeout(() => setNow(Date.now()), delay);
+ return () => window.clearTimeout(id);
+ }, [now, trialEndsAt]);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| useEffect(() => { | |
| const remaining = trialEndsAt - Date.now(); | |
| const interval = remaining < 60 * 60 * 1000 ? 1_000 : 60_000; | |
| const id = window.setInterval(() => setNow(Date.now()), interval); | |
| return () => window.clearInterval(id); | |
| }, [trialEndsAt]); | |
| useEffect(() => { | |
| const remaining = trialEndsAt - now; | |
| if (remaining <= 0) return; | |
| const delay = remaining < 60 * 60 * 1000 ? 1_000 : 60_000; | |
| const id = window.setTimeout(() => setNow(Date.now()), delay); | |
| return () => window.clearTimeout(id); | |
| }, [now, trialEndsAt]); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@mcpjam-inspector/client/src/components/sidebar/sidebar-trial-countdown.tsx`
around lines 18 - 23, In the sidebar-trial-countdown component useEffect, the
interval is computed once from trialEndsAt so the tick cadence never tightens
when remaining time drops below an hour; change the logic to schedule/reschedule
on each tick (for example replace the fixed setInterval with a self-rescheduling
timer or clear-and-set a new timer inside the callback) so you compute remaining
= trialEndsAt - Date.now() on every tick and choose 1000ms or 60000ms
accordingly; ensure you still call setNow(Date.now()) each tick and properly
clear the timeout/interval in the cleanup to avoid leaks (refer to useEffect,
setNow, the interval id variable).
Sidebar trial countdown